<?php require_once('menu.php'); ?>
<table width="100%" class="menubar" cellpadding="0" cellspacing="0" border="0">
    <tr>
        <td class="menudottedline" width="40%">
        <?php
         if (isset($alert)) {
         ?>
            <div class="pathway">Alert:&nbsp;<?=$alert?></div>
        <?php
         }
         ?>
        </td>
        <td class="menudottedline" align="right">
            <table cellpadding="0" cellspacing="0" border="0" id="toolbar">
                <tr height="60" valign="middle" align="center">
                    <td>
                        <a class="toolbar" href="javascript: document.getElementById('flag').value='add'; submitthis();">
                        <?php echo $html->image('admin/copy_f2.png', array('align' => 'middle', 'border' => 0)); ?><br>Add
                        </a>
                    </td>
                    <td>
                        <a class="toolbar" href="javascript: document.getElementById('flag').value='delete'; submitthis();">
                        <?php echo $html->image('admin/cancel_f2.png', array('align' => 'middle', 'border' => 0)); ?><br>Delete
                        </a>
                    </td>
                    <td>
                        <a class="toolbar" href="#">
                        <?php echo $html->image('admin/help_f2.png', array('align' => 'middle', 'border' => 0)); ?><br>Help
                        </a>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>
<br>
<br>
<div align="center" class="centermain">
    <div class="main">
        <table class="adminheading">
            <tr>
                <th class="info" rowspan="2" nowrap>Manage Offers</th>
            </tr>
        </table>

        <form id="adminForm" name="adminForm" method="post" action="<?=$html->url('/admin/manage_offers')?>" enctype="multipart/form-data">
        <input type="hidden" id="flag" name="data[flag]" />
        <table class="adminform">
            <tr>
                <td width="70%" valign="top">
                    <div class="error"></div>
                    <table class="adminlist" cellpadding=20>
                    	<tr>
                    		<th colspan="7">Offer Lists</th>
                    	</tr>
                        <tr bgcolor="#ae1d1d">
                            <td width="3%" class="subheader"><input type="checkbox" id="toggle1" onclick="checkAllId();"></td>
                            <td width="5%" class="subheader">#</td>
                            <td width="20%" class="subheader">Offer Name</td>
                            <td width="15%" class="subheader">Ad Network</td>
                            <td width="12%" class="subheader">Category</td>
                            <td width="%" class="subheader">Keyword</td>
                            <td width="5%" class="subheader">&nbsp;</td>
                        </tr>

                    <?php
                     if($offers){
                        foreach($offers as $idx => $v){
                            $color = ($idx/2 == round($idx/2)) ? "row0" : "row1";
                     ?>
                        <tr class="<?=$color?>">
                            <td>
                                <input type="checkbox" id="nt<?=$idx?>" name="data[row][id][]"
                                       value="<?=$v['Offer']['id']?>" onclick="isChecked(this.checked);">
                            </td>
                            <td><?php echo $idx + 1; ?></td>
                            <td><?php echo $html->link($v['Offer']['offer_name'], '/admin/add_offers/'.$v['Offer']['id']);?></td>
                            <td><?php echo $v['Offer']['ad_network'];?></td>
                            <td><?php echo $v['Offer']['category'];?></td>
                            <td><?php echo $v['Offer']['keywords'];?></td>
                            <td>&nbsp;</td>
                        </tr>
                    <?php
                        }
                     ?>
                        <tr>
                            <td colspan="7" align="center">
                                <?php
                                 if (isset($paginator)) {
                                    echo $paginator->numbers();
                                    echo $paginator->counter();
                                 }
                                 ?>
                            </td>
                        </tr>
                    <?php
                     } else {
                     ?>
                    <tr>
                        <td colspan="7">No Result Found</td>
                    </tr>
                    <?php
                     }
                     ?>
                    </table>
                    <input type="hidden" name="boxchecked" value="0">


                </td>
                <td width="30%" valign="top">
                    <table class="adminform">
                        <tr>
                            <th>Search Offer</th>
                        </tr>
                        <tr>
                            <td>
                                <input type="text" name="data[search][value]" style="width: 250px;">
                                <input type="submit" value="Search" class="button">
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
        </form>

    </div>
</div>

<script language="JavaScript">
<!--
function checkAllId()
{
    var num = '<?php echo $offerCount;?>';
    checkAll(num, 'nt', 'toggle1');
}
function submitthis()
{
    var flag = document.getElementById('flag').value;
    switch (flag) {
        case "enable":
            var msg = "Clicking this button will enable selected advertiser";
            alert(msg)
            document.adminForm.submit();
        break;

        case "disable":
            var msg = "Are you sure you want to disable the selected advertiser?";
            if (confirm(msg)) {
                document.adminForm.submit();
            }
        break;

        case "delete":
            var msg = "Are you sure you want to delete the selected advertiser?";
            if (confirm(msg)) {
                document.adminForm.submit();
            }
        break;

        default:
            document.adminForm.submit();
        break;
    }
}
-->
</script>